//
//  BQHomeScrollCell.m
//  BeeQuick
//
//  Created by mac on 16/11/22.
//  Copyright © 2016年 six_group. All rights reserved.
//

#import "BQHomeScrollCell.h"
#import "BQHomeScrollFlowLayout.h"
#import <UIImageView+WebCache.h>
static NSString *cellID = @"cellID";
@interface BQHomeScrollCell()<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>



@end
@implementation BQHomeScrollCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self setupUI];
    }
    return self;
}


- (void)setupUI
{
    
    
//    self.backgroundColor = [UIColor grayColor];
    
    BQHomeScrollFlowLayout * flayout = [[BQHomeScrollFlowLayout alloc]init];
 
    
    UICollectionView * colView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flayout];
    colView.backgroundColor = [UIColor cz_colorWithHex:0xefefef];
    
    [self.contentView addSubview:colView];
    
    
    [colView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
        
    }];
    
    colView.dataSource = self;
    
    [colView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:cellID];
    
    
    
    colView.showsHorizontalScrollIndicator = NO;
    colView.bounces = NO;
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
   return self.scrollArr.count;
    
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
    
    UIImageView *pic = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 140)];
    [pic sd_setImageWithURL:[NSURL URLWithString:self.scrollArr[indexPath.row].activity.img]];
    cell.backgroundView = pic;
    

    
    return cell;
}

#pragma mark - 分别修改 每一组的 item之间的间距
//- (CGFloat)collectionView:(UICollectionView *)collectionView
//                   layout:(UICollectionViewLayout *)collectionViewLayout
//minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
//{
//   
//    return kScale ;
//}
//
//- (CGFloat) collectionView:(UICollectionView *)collectionView
//                    layout:(UICollectionViewLayout *)collectionViewLayout
//minimumLineSpacingForSectionAtIndex:(NSInteger)section
//{
//   
//    return kScale;
//}





@end
